package first.niuke.simple;

/**
 * @ClassName NC25
 * @description:
 * @author: 荣燊
 * @create: 2021-06-16 10:25
 **/
public class NC25 {
    // 删除有序链表中的重复元素
    public ListNode deleteDuplicates (ListNode head) {
        // write code here
        if (head == null || head.next == null) {
            return head;
        }

        ListNode node = head;

        while (node != null && node.next != null) {
            if (node.val == node.next.val) {
                node.next = node.next.next;
            } else {
                node = node.next;
            }
        }

        return head;
    }


    public class ListNode {
        int val;
        ListNode next = null;
    }
}
